from common.LoggerFactory import Log
from config import configuration
from service_file import MinioService, RedisUtils
from service_rpc import route_entrance
from service_rpc.api import rpc_file_api, rpc_sms_api, web_hook_api


def init():
    if configuration.ENABLE_MINIO:
        MinioService.SingleMinioClient()
    if configuration.ENABLE_CACHE:
        RedisUtils.SingleRedisClient()


if __name__ == "__main__":
    init()
    Log.console().info("^_^成功启动扩展服务，请不要关闭窗口！")
    rpc_sms_api.RegisterMethod()
    rpc_file_api.RegisterMethod()
    web_hook_api.RegisterMethod()
    route_entrance.Entrance()
    route_entrance.app.run(host=configuration.SERVER_HOST, port=configuration.SERVER_PORT)
